#! /usr/bin/env	python
#encoding=utf-8

import MySQLdb,string,os,sys
from random import Random

def random_str(randomlength=8):
    str = ''
    #chars = 'AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz0123456789'
    chars ='abcdefghijklmonpqrstuvwxyz0123456789'
    length = len(chars) - 1
    random = Random()
    for i in range(randomlength):
        str+=chars[random.randint(0, length)]
    return str

try:
	conn = MySQLdb.connect (host ='10.102.107.22',user ='dba',passwd = '1q2w3e4r',db = 'mc_userdb',charset="utf8")
except MySQLdb.Error, e:
	print "Error %d: %s \n" % (e.args[0], e.args[1])

try:
	for i in range(0,10000):
		login_name=random_str()
		SQLStr="""insert into customer_login(login_name,password) values('%s',md5('%s'));"""%(login_name,login_name)
		cursor = conn.cursor(MySQLdb.cursors.DictCursor)
		cursor.execute(SQLStr)
		cursor.execute('commit')
	cursor.close()
	conn.close()
except MySQLdb.Error,e:
	print "Error %d: %s \n" % (e.args[0], e.args[1])